<template>
    <div id="app">
        <hb-head headfont="积分明细"></hb-head>
        <div class="mui-content">
            <div class="mui-card">
                <div class="mui-card-content">
                    <div class="content-banner">
                        <div class="text-button">
                            <span class="header-text">{{(user.score - user.frozen_score) / 100}}</span>
                            <span>可用积分</span>
                        </div>
                        <div class="text-button">
                            <span class="header-text">{{user.frozen_score / 100}}</span>
                            <span>待解冻积分</span>
                        </div>
                    </div>
                </div>
            </div>

            <ul class="slg mui-table-view mui-table-view-chevron">
                <li v-for="item in score_record" class="mui-table-view-cell mui-media" style="text-align: left;">
                    <div class="mui-media-body">
                        {{ item.content }} {{ item.change > 0 ? '+' + (item.change / 100) : (item.change / 100) }}
                    </div>
                </li>
            </ul>
        </div>
        <order-list :activeCategory="activeCategory"></order-list>
    </div>
</template>

<script>

  import {ajax, userSettings, userRedirect, callWechatPay} from 'assets/js/Lib'

  import 'assets/css/mui.css'

  import HbHead from 'components/HbHead'
  import NavBarTab from 'components/NavBarTab'
  import OrderList from 'components/OrderList'

  export default {
    data() {
      return {
        score_record: [],
        user: null,
      }
    },
    components: {
      HbHead, NavBarTab, OrderList
    },
    computed: {},
    //实例初始化最之前，无法获取到data里的数据
    beforeCreate() {

    },
    //在挂载开始之前被调用
    beforeMount() {

    },
    //已成功挂载，相当ready()
    mounted() {

      const vm = this;
      ajax({
        url: '/api/user/score_record',
        type: 'GET',
        success: (res) => {
          vm.score_record = res
        }
      })

      this.user = JSON.parse(localStorage.getItem('$userData')).user;

      mui.init({
        statusBarBackground: '#f7f7f7'
      })
    },
    //相关操作事件
    methods: {}
  }
</script>

<style lang="less">
    .content-banner {
        height: 60px;
    }

    .text-button {
        width: 24.99%;
        height: inherit;
        float: left;
        padding: 15px;
        cursor: pointer;

        &:active {
            background: #eee;
        }

        span {
            display: block;
            font-size: 12px;
            line-height: 12px;
            color: #232326;
            text-align: center;
        }

        span.header-text {
            font-size: 16px;
            line-height: 16px;
            margin-bottom: 6px;
        }
    }

    .img-button {
        width: 33.33%;
        height: inherit;
        float: left;
        padding: 15px;
        cursor: pointer;

        &:active {
            background: #eee;
        }

        img {
            width: 100%;
            height: 100%;
        }

        span.button-header {
            width: 21px;
            height: 18px;
            margin: 0 auto;
            margin-bottom: 4px;
            position: relative;
            display: block;

            .mui-badge {
                position: absolute;
                right: -15px;
                top: -10px;
            }
        }

        span.button-footer {
            display: block;
            font-size: 11px;
            line-height: 11px;
            color: #232326;
            text-align: center;
            margin-bottom: 4px;
        }
    }

    #app {

        img.slg {
            width: 15px;
            height: 18px;
        }

        .mui-table-view ~ .mui-card {
            margin-top: -2px;
        }

        .mui-table-view-cell {
            &:after {
                left: 0px;
            }
        }

        .mui-navigate-right {
            padding: 10px 65px 10px 11px;
            font-size: 14px;
            min-height: 32px;
        }

        .mui-navigate-right > .text {
            color: #bbb;
            right: 35px;
            position: absolute;
            top: 28%;
        }

        .mui-card {
            margin: 15px 0 10px 0;
            border-radius: 0px;
            box-shadow: 0 0px 1px rgba(0, 0, 0, .3);
        }

        .mui-table-view {
            /*margin-top: 25px;*/
        }
    }
</style>
